<template>
  <div id="chartBar" :style="{ width: '100%', height: '100%' }"></div>
</template>

<script>
export default {
  data() {
    return {
      chartOption: {
        title: {
          text: '终端套利用户量（前10排名，单位：百万）',
          left: 'center'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: {
          type: 'value',
          boundaryGap: [0, 0.01]
        },
        yAxis: {
          type: 'category',
          data: [
            '广东',
            '浙江',
            '江西',
            '上海',
            '黑龙江',
            '新疆',
            '陕西',
            '湖南',
            '四川',
            '湖北'
          ]
        },
        series: [
          {
            name: '本季度违规用户量（前10排名）',
            type: 'bar',
            data: [1.2, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.2].reverse(),
            barWidth: 20,
            itemStyle: {
              normal: {
                color: '#F4D03F',
                label: { show: true },
                lineStyle: {
                  color: '#F4D03F'
                }
              }
            }
          }
        ]
      }
    }
  },

  mounted() {
    this.drawLine()
  },

  methods: {
    drawLine() {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('chartBar'))
      // 绘制图表
      myChart.setOption(this.chartOption)
    }
  }
}
</script>

<style lang="scss" scoped></style>
